<template>
  <view class="page-loading-container" v-if="show">
    <view class="loading-content">
      <view class="loading-spinner">
        <view class="spinner-ring" :style="{borderTopColor: primaryColor}"></view>
      </view>
      <text class="loading-text" :style="{color: primaryColor}">{{ loadingText }}</text>
    </view>
  </view>
</template>

<script>
export default {
  name: 'PageLoading',
  props: {
    show: {
      type: Boolean,
      default: true
    },
    loadingText: {
      type: String,
      default: '加载中...'
    },
    primaryColor: {
      type: String,
      default: '#4A90E2'
    }
  }
}
</script>

<style lang="scss" scoped>
.page-loading-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  
  .loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    
    .loading-spinner {
      width: 80rpx;
      height: 80rpx;
      margin-bottom: 32rpx;
      
      .spinner-ring {
        width: 100%;
        height: 100%;
        border: 6rpx solid #f3f3f3;
        border-top: 6rpx solid #4A90E2;
        border-radius: 50%;
        animation: spin 1s linear infinite;
      }
    }
    
    .loading-text {
      font-size: 28rpx;
      color: #4A90E2;
      opacity: 0.8;
    }
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style>